<template>
    <div class="ps-main-container">
        <mt-header :title="cityDetail.currentCityName">
            <router-link to="/" slot="left">
                <mt-button icon="back">返回</mt-button>
            </router-link>
            <router-link to="/home" slot="right">
                <div>切换城市</div>
            </router-link>
        </mt-header>
        <mt-search
                @input="cityUpdateSearchVal"
                cancel-text="取消"
                placeholder="输入学校、商务楼、地址">
        </mt-search>
        <mt-button v-waves type="primary" size="large" @click="cityGetSearchPlace(cityId)">提交</mt-button>
        <ul v-if="cityDetail.searchPlaceList.length">
            <li v-for="(item, index) in cityDetail.searchPlaceList" class="ps-border-bot" @click="nextPage(item.geohash)">
                <p class="ps-search-title">{{item.name}}</p>
                <p>{{item.address}}</p>
            </li>
        </ul>
        <no-data :data-arr="cityDetail.searchPlaceList"></no-data>
    </div>
</template>
<style lang="less" scoped>
    @import "./../../assets/css/variable_gather";
    .ps-search-title{
        .font-dpr(15px);
    }
    .ps-border-bot{
        .onePxBottomByBg(@dark-border);
        .line-half();
    }
</style>
<script>
    import {mapState, mapGetters, mapActions} from 'vuex'
    import noData from './../../components/partly/noData.vue'
    import {cityUd} from 'store/modules/types'
    export default{
        data(){
            return{
                cityId: '',
                ddd: []
            }
        },
        components:{
            noData
        },
        computed:{
            ...mapGetters({
                'cityDetail': 'cityDetailState'
            })
        },
        methods:{
            ...mapActions({
                'cityInitParams': cityUd.A.INIT_PARAMS,
                'cityGetCurrentCity': cityUd.A.GET_CURRENT_CITY,
                'cityUpdateSearchVal': cityUd.A.GET_SEARCH_VAL,
                'cityGetSearchPlace': cityUd.A.GET_SEARCH_PLACE
            }),
            nextPage(geoHash){
                this.$router.push({path:'/msite', query:{geoHash: geoHash}})
            }
        },
        created(){
            this.cityId = this.$route.params.cityId
            this.cityInitParams()
        },
        mounted(){
            this.cityGetCurrentCity(this.cityId)
        }
    }
</script>
